/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ourpkr.model;

import java.util.*;
import java.beans.*;

/**
 *
 * @author niboucha
 */
public class EnsembleCartes {

    public PropertyChangeSupport pcs;

    public EnsembleCartes(boolean full) {
        pcs = new PropertyChangeSupport(this);
        setCartes(new Vector<Carte>());
        if (full) {
            for (int i = 1; i < 14; i++) {
                for (int j = 1; j < 5; j++) {
                    addACarte(new Carte(i, j));
                }
            }
        }

    }

    public void addACarte(Carte c) {
        cartes.add(c);
        pcs.firePropertyChange("cartes", null, cartes);
    }
    
    public Carte carteAt(int i){
        return cartes.elementAt(i);
    }

    public void removeACarte(Carte c) {
        cartes.remove(c);
        pcs.firePropertyChange("cartes", null, cartes);
    }

    public Carte removeACarte(int i) {
        Carte c = cartes.remove(i);
        pcs.firePropertyChange("cartes", null, cartes);
        return c;
    }

    public void mix() {
        Collections.shuffle(cartes);
        pcs.firePropertyChange("cartes", null, cartes);
    }

    public String toString() {
        String result = "";
        for (int i = 0; i < cartes.size(); i++) {
            result += cartes.get(i).toString();
            if (i < cartes.size() - 1) {
                result += ", ";
            }
        }
        return result;
    }

    public int bestCombValue() {
        int value = asQuinteFlushR();
        if (value > 0) {
            return value;
        }
        //value = asQuinteFlush();
        return 0;
    }

    private int asQuinteFlushR() {
        return 0;
    }

    public com.sampullara.poker.Cards getLibCards() {
        com.sampullara.poker.Cards ensC = new com.sampullara.poker.Cards();
        for (int i = 0; i < cartes.size(); i++) {
            ensC.add(cartes.get(i).getLibCard());
        }

        return ensC;
    }
    /*private Vector<EnsembleCartes> combinCartes(EnsembleCartes restant, int size){
    Vector<EnsembleCartes> out = new Vector<EnsembleCartes>();
    for(int i = 0; i < cartes.size() ; i++){
    cartes.get(i);
    //A FINIR
    }
    return null;
    }*/
    private Vector<Carte> cartes;
    public int getSize(){
        return cartes.size();
    }
    
    public void setCartes(Vector<Carte> cartes) {
        this.cartes = cartes;
        pcs.firePropertyChange("cartes", null, this.cartes);
    }
}
